def make_word(a, b)
  value = (((a & 0x000000ff)) | (((b & 0x000000ff))) << 8)
end

def make_long(a, b) {
  value = ((a & 0x0000ffff) | (b & 0x0000ffff) << 16)
end

def lo_word(a)
  value = (a & 0x0000ffff)
end

def hi_word(a)
  value = (a >> 16)
end

def lo_byte(a)
  value = (a & 0x000000ff)
end

def hi_byte(a)
  value = (a >> 8)
end

# read and write functions

def read_color_ref(stream, color)
  color_ref = read_integer(stream)
  color[0] = lo_byte(lo_word(color_ref))
  color[1] = hi_byte(lo_word(color_ref))
  color[2] = lo_byte(hi_word(color_ref))
end

def write_color_ref(stream, color) 
  color_ref = make_long(make_word(color[0], color[1]), make_word(color[2], 0))
  write_integer(stream, color_ref)
end

def read_mfc_rect(stream, rect)
  4.times do |i|
    rect[i] = read_signed_integer(stream)
  end
end

def write_mfc_rect(stream, rect)
  4.times do |i|
    write_signed_integer(stream, rect[i])    
  end
end

def read_byte(stream)

end

def write_byte(stream, data)

end
